package com.lingz.manager.modules.sms.controller;

import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.exceptions.ClientException;
import com.lingz.manager.common.utils.ResultUtil;
import com.lingz.manager.common.vo.Result;
import com.lingz.manager.modules.sms.utils.AliyunSmsUtils;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: hanyuhang
 * @Description:
 * @Date:Create: 2023/9/26 9:48
 * @Modify:
 */
@Api(tags = "短信")
@RestController
@RequestMapping(value = "/EnjoyGIS/sms")
public class sms {
    @Value("${aliyun.accessKeyId}")
    private String accessKeyId;

    @Value("${aliyun.accessKeySecret}")
    private String accessKeySecret;

    @Value("${aliyun.signName}")
    private String signName;

    @Value("${aliyun.templateCode}")
    private String templateCode;

    @Value("${aliyun.domain}")
    private String domain;

    @Value("${aliyun.product}")
    private String product;

    @RequestMapping("/sendSms")
    public Result<SendSmsResponse> sendSms(String phone){
        AliyunSmsUtils aliyunSmsUtils = new AliyunSmsUtils();
        SendSmsResponse sendSmsResponse = new SendSmsResponse();
        try {
            sendSmsResponse = aliyunSmsUtils.sendSms(accessKeyId, accessKeySecret, phone, signName, templateCode, domain, product);
        } catch (ClientException e) {
            e.printStackTrace();
        }
        return new ResultUtil<SendSmsResponse>().setData(sendSmsResponse);
    }
}